package com.mytest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

@RestController
public class MyController {

    @Autowired
    MessageProducer messageProducer;
    @Autowired
    Session session;
    @Autowired
    MovieService movieService;
    @Autowired
    Movie movie;

    @GetMapping("/send")
    public String findById() throws JMSException {


        //6. 发送消息
        for (int i=0;i<5;i++){

            TextMessage textMessage = session.createTextMessage("Hello,MQ3"+i);
            messageProducer.send(textMessage);

        }

        return "ok";
    }

    @GetMapping("/getFilm")
    public String getFilm() {

        String film = movieService.getFilm();
        return film;
    }

    @GetMapping("/getFilm1")
    public Movie getFilm1() {


        return movie;
    }
}
